Release 10.1A: OpenEdge Development:
ProDataSets


Query OFF-END Event

There has long been an OFF-END GUI event for the Progress browse control. Developers can use this to detect the end of the available data in the query the browse is displaying. For example, you could then retrieve additional batches of data and append them to the rows in the table and re-open the query so that they are added to the browse. The ProDataSet supports an OFF-END event for its temp-table queries. It takes care of this function for you, so that you do not need to code an OFF-END browse trigger block to handle this, or even depend on there being a browse at all. In addition, Progress queries have a QUERY-OFF-END condition you can use to detect the end of the query’s data when you are navigating through the data programmatically. The ProDataSet event can respond to this case as well, when there is no browse to trigger a GUI event. Regardless of how the end-of-data condition is detected, the query itself can respond to running out of rows so that an event handler can react appropriately, whether it is to retrieve more data from the server or take other action.

The OFF-END event is available for any query on a ProDataSet temp-table. The OFF-END event occurs when the query is positioned beyond the last row in the query, no matter how this is done. This can be because of a browse scroll to the end of the query, or a GET-NEXT() method or GET NEXT statement on the query beyond the last row.

This event can be attached to the query handle using the same SET-CALLBACK-PROCEDURE method the FILL events use, as shown in the following context:

Syntax
query-handle:SET-CALLBACK-PROCEDURE(“OFF-END”, event-procedure   
                                    [, procedure-handle ] ). 

Where:

In keeping with the calling sequence for the FILL and temp-table change events, the ProDataSet is passed in as an INPUT parameter implicitly BY-REFERENCE, providing the event procedure full access to all the data at no cost (because there is no copying of data involved). And as with other callback events, your code can use the APPLY-CALLBACK method to invoke the event handler programmatically.

A typical use of these events would be to fetch additional batches of data from the server if not all data has been retrieved and sent to the client. The event handler for OFF-END can find the last currently available row and pass its key to the server as a starting point for the next batch. There’s an example of using this technique to provide data batching later in Chapter 8, " Batching Data with ProDataSets." The event procedure can of course also look at other information in the ProDataSet, including the current row in other tables (so that the query requesting more data could identify the parent for example), and whatever else is helpful.

Note that this event is similar to the existing QUERY-OFF-END query attribute. The difference is that the QUERY-OFF-END attribute is a condition that must be tested at a specific place in the application code, whereas the callback event procedure executes whenever the condition occurs regardless of where it happens in the application code or the user interface. This allows a single event handler to be executed whenever the condition occurs.

There are several pointers on the use of this event:

The "Buffer BATCH-SIZE and LAST-BATCH attributes" section shows how to use the OFF-END event to providing batching for an application window when you need to be able to scroll seamlessly through a large number of rows that cannot be retrieved all at once.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095